package com.yic.module.wms.api.warehouse;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.yic.module.wms.api.brand.WarehouseApi;
import com.yic.module.wms.api.brand.dto.WarehouseRespDTO;
import com.yic.module.wms.convert.warehouse.WarehouseConvert;
import com.yic.module.wms.dal.dataobject.warehouse.WarehouseDO;
import com.yic.module.wms.service.warehouse.WarehouseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @Author: Ljx
 * @createTime: 2024年01月02日 14:08:04
 * @version: v1.0.0
 * @Description: 仓库API实现
 */
@Service
public class WarehouseApiImpl implements WarehouseApi {

    @Resource
    private WarehouseService warehouseService;

    @Override
    public WarehouseRespDTO getWarehouse(Long id) {
        if (ObjectUtil.isEmpty(id)) {
            return null;
        }
        WarehouseDO warehouse = warehouseService.getWarehouse(id);
        return WarehouseConvert.INSTANCE.convert01(warehouse);
    }

    @Override
    public WarehouseRespDTO getWarehouseByErpId(String erpWarehouseId) {
        if (ObjectUtil.isEmpty(erpWarehouseId)) {
            return null;
        }
        WarehouseDO warehouse = warehouseService.getWarehouseByErpId(erpWarehouseId);
        return WarehouseConvert.INSTANCE.convert01(warehouse);
    }

    @Override
    public List<WarehouseRespDTO> getWarehouseListByErpId(Collection<String> erpWarehouseIds) {
        if (CollectionUtil.isEmpty(erpWarehouseIds)) {
            return Collections.emptyList();
        }
        List<WarehouseDO> list = warehouseService.getWarehouseListByErpId(erpWarehouseIds);
        return WarehouseConvert.INSTANCE.convertList04(list);
    }
}
